home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / gcc / libnix.lha / gnu / lib / libnix / sources.lha / nix / string / strchr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-09  |  434 b   |  38 lines

  1. #ifndef mc68000
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. asm(".globl _index;_index:;jmp pc@(_strchr-.+2)");
  7.  
  8. char *strchr(const char *s,int c)
  9. {
  10.   while (*s!=(char)c)
  11.     if (!(*s++))
  12.     {
  13.       s=NULL;
  14.       break;
  15.     }
  16.   return (char *)s;
  17. }
  18.  
  19. #else
  20.  
  21. asm("
  22.     .globl    _index
  23.     .globl    _strchr
  24. _index:
  25. _strchr:
  26.     movel    sp@(4:W),a0
  27.     movel    sp@(8:W),d0
  28. L2:    cmpb    a0@,d0
  29.     jeq    L1
  30.     tstb    a0@+
  31.     jne    L2
  32.     subal    a0,a0
  33. L1:    movel    a0,d0
  34.     rts
  35. ");
  36.  
  37. #endif
  38.